//
//  SelectCoursesDetailVC.m
//  Menu
//
//  Created by mc on 16/4/12.
//  Copyright © 2016年 xmj. All rights reserved.
//

#import "SelectCoursesDetailVC.h"
#import "UMSocial.h"
#import "MBProgressHUD.h"
#import "SelectCourses.h"
#import "MJExtension.h"
#import "CoursesDetaileFirstCell.h"
#import "CoursesDetaileSecondCell.h"
#import "CoursesDetaileThirdCell.h"

@interface SelectCoursesDetailVC()<UITableViewDataSource,UITableViewDelegate,UMSocialUIDelegate>
@property (nonatomic, strong) UITableView *tableView;


@end

@implementation SelectCoursesDetailVC


- (UITableView*)tableView

{
    if(_tableView==nil) {
        _tableView= [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
        _tableView.dataSource = self;
        _tableView.delegate = self;
        
    }
    return _tableView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.tableView];
    self.navigationItem.title = @" ";
    UIButton *shareButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, 36)];
    [shareButton setBackgroundImage:[UIImage imageNamed:@"shareImg"] forState:UIControlStateNormal];
    [shareButton addTarget:self action:@selector(shareMessage) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithCustomView:shareButton];
    self.navigationItem.rightBarButtonItem = rightButton;
    [self.tableView reloadData];
}

//- (void)loadData{
//    // 利用MJExtension框架进行字典转模型
//    //self.selectCourses = [SelectCourses mj_objectArrayWithKeyValuesArray:self.dict];
//    // 刷新数据（若不刷新数据会显示不出）
//    [self.tableView reloadData];
//}

- (void)shareMessage{
    
    //    [[UMSocialControllerService defaultControllerService] setShareText:@"分享内嵌文字" shareImage:[UIImage imageNamed:@"img_01"] socialUIDelegate:self];        //设置分享内容和回调对象
    //    [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToSina].snsClickHandler(self,[UMSocialControllerService defaultControllerService],YES);
    
    [UMSocialSnsService presentSnsIconSheetView:self
                                         appKey:@"570504a5e0f55a16b8001c03"
                                      shareText:@"你要分享的文字"
                                     shareImage:[UIImage imageNamed:@"img_01"]
                                shareToSnsNames:[NSArray arrayWithObjects:UMShareToSina,UMShareToWechatSession,UMShareToWechatTimeline,UMShareToQQ,nil]
                                       delegate:self ];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
   
    CoursesDetaileFirstCell *cell = [CoursesDetaileFirstCell coursesDetailFirstCellWithTableView:self.tableView];
    cell.selectCourses = self.selectCourse;
    [cell layoutIfNeeded];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    SelectCourses *selectCourseMes = self.selectCourse;
    return [CoursesDetaileFirstCell height:selectCourseMes];
}


- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.1;
}

@end
